home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4471 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.7 KB

  1. Path: news.mindlink.net!news
  2. From: genew@mindlink.bc.ca (Gene Wirchenko)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: void main() and other atrocities!
  5. Date: Sun, 04 Feb 1996 21:00:56 GMT
  6. Organization: MIND LINK! - British Columbia, Canada
  7. Message-ID: <4f36ts$j9k@fountain.mindlink.net>
  8. References: <4eduaj$1aq@grouper.Exis.Net> <4epplj$egf@host-3.cyberhighway.net> <4erjn2INN38b@keats.ugrad.cs.ubc.ca> <9602021300.AA04359@dxmint.cern.ch> <4f2rahINNmud@keats.ugrad.cs.ubc.ca>
  9. NNTP-Posting-Host: line062.nwm.mindlink.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) wrote:
  13.  
  14. [snipped previous poster's material]
  15.  
  16. >I know that it would break a compiler that generates an incompatible linkage
  17. >for functions returning int and void functions (assuming that the function you
  18. >are calling does not return). But I just don't know of any that do (and it
  19. >would be silly to write one that generates subroutine linkage code which breaks
  20. >when a void function is called that is assumed to be int).
  21.  
  22.      Better not to find out as in gotcha.
  23.  
  24. >It's also atrocious that main() has to be treated as a special language
  25. >construct, and that a call to exit() in main() (when it is the last statement)
  26. >is to be identical to a return.
  27.  
  28.      Why?  main() IS a special language construct: it starts the
  29. program.
  30.  
  31. >I don't advocate that people declare main() to return void (in fact I don't do
  32. >so myself), but I don't see it as some sort of big mistake. In my own coding, I
  33. >sometimes even define the argv/argc parameters even if I don't use them, just
  34. >to meet the implicity prototype.
  35.  
  36.      I do, too.  After all, I may expand the program and need them.
  37.  
  38. >I did read the relevant section in the FAQ. It is merely concerned with the
  39. >issue of eliminating compiler warnings stemming from calling exit() in main()
  40. >despite a "void" declaration thereof. The issue that a void function may
  41. >not be compatible with a call to an int function doesn't seem that significant,
  42. >since nobody in their right mind would design a compiler that way.
  43.  
  44.      Why not?  After all, no one in their right mind would declare
  45. void main() <G>.
  46.  
  47. >In any case, I program using ANSI C only about 30% of the time. The
  48. >old-fashioned function declarations are more elegant. The only truly useful
  49.  
  50.      "elegant" does not mean more error prone.
  51.  
  52. >thing introduced in ANSI C is the standardization of variable-length arg list
  53. >handling.  It's the only thing I really miss when working with non-ANSI
  54. >compilers. The other things I can handle myself: for instance, I don't need the
  55. >compiler promoting arguments to their prototyped types for me. An explicit cast
  56. >is more conscientious.
  57.  
  58.      It's also clerk work.  I'm a programmer/analyst myself.  If the
  59. language can help me, I'll use the help.  If you cast, the promotions
  60. won't be done.
  61.  
  62. >There is something magical about the old-style C that attracts me. I can't
  63. >quite put my finger on it. I was once a very good, careful coder. I wrote neat
  64. >programs in Modula 2 and similar langauges, always had carefully designed
  65. >abastract data types. All my cardinal variables belonged to carefully declared
  66. >and typed domains, arrays had typed ranges, etc.  It all went down hill from
  67. >there!
  68.  
  69.      And now you've found religion?  The previous paragraph is
  70. feelings/opinions only.  How did it do down hill?
  71.  
  72. >Now I'm increasingly catching myself writing assembly code, as though I had
  73. >gone full-circle. The arguments of what a main() function ought to be sound
  74. >like the buzzing of flies to me.
  75.  
  76.      Ditto.
  77.  
  78. >Can someone else identify with me? :)
  79.  
  80.      No, but I can identify you.
  81.  
  82. >-- 
  83.  
  84. Sincerely,
  85.  
  86. Gene Wirchenko
  87.  
  88. C Pronunciation Guide:
  89.      y=x++;     "wye equals ex plus plus semicolon"
  90.      x=x++;     "ex equals ex doublecross semicolon"
  91.  
  92.